#include <string.h>
#include "server.hpp"

Server::Server() {
	if (!server.Listen(Port)) {
		std::cerr << "Erreur : impossible d'écouter" << std::endl;
	}
	
	
}

void Server::Run() {
	char message[128];
	std::size_t size;
	server.Accept(client, &adresse_client);
	std::cout << "Client connected : " << adresse_client << std::endl;
	while (strcmp(message, "END") != 0) {
		if (client.Receive(message, sizeof(message), size) != sf::Socket::Done) {
			std::cerr << "Erreur : Réception erronée" << std::endl;
		}
		std::cout << "Server : " << message << std::endl;
	}
	std::cout << "Fermeture Server" << std::endl;
	
	client.Close();
	server.Close();
}



